package com.offer;

import com.bean.TreeNode;
import com.bean.TreeOperationUtils;

import java.util.Deque;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;

public class Test9 {

    Deque<Integer> stack1 = new LinkedList<>();
    Deque<Integer> stack2 = new LinkedList<>();

    public void appendTail(int value) {
        stack1.push(value);
    }

    public int deleteHead() {
        while (stack2.isEmpty()) {
            while (!stack1.isEmpty()) {
                stack2.push(stack1.pop());
            }
            break;
        }

        if (stack2.isEmpty()) {
            return -1;
        } else {
            return stack2.pop();
        }
    }

    public static void main(String[] args) {
        int[] preorder = new int[]{3, 9, 20, 15, 7, 6};
        int[] inorder = new int[]{9, 3, 15, 20, 7, 6};

        Test9 test7 = new Test9();
        test7.appendTail(1);
        test7.appendTail(2);
        test7.appendTail(3);

        System.out.println(test7.deleteHead());
        System.out.println(test7.deleteHead());
        System.out.println(test7.deleteHead());
        System.out.println(test7.deleteHead());
    }

}
